home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 926 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.4 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: clamage@Eng.Sun.COM (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Referencing pointers after delete
  5. Date: 01 Apr 1996 10:39:37 PST
  6. Organization: Sun Microsystems Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4jp5dv$lbj@engnews1.Eng.Sun.COM>
  9. References: <4jmibl$qvt@mulga.cs.mu.OZ.AU>
  10. Reply-To: clamage@Eng.Sun.COM
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. X-Original-Date: 1 Apr 1996 17:57:19 GMT
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMWAi60y4NqrwXLNJAQFH/gH+L4SgTUxqf4cFjK0K1wEBHoljPB1J2Vhn
  15.     6G++zpgTs3p6sMyBQvHG2pG04HDRswtxP/DpFuRvuLulYEPFjKNFDg==
  16.     =YDyU
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article qvt@mulga.cs.mu.OZ.AU, fjh@mundook.cs.mu.OZ.AU (Fergus Henderson) writes:
  20. >
  21. >I don't think there is any disagreement about whether it IS undefined
  22. >behaviour; the question is about whether it should be.  Remember, every
  23. >instance in which the standard leaves the behaviour undefined is one
  24. >more hurdle for programmers trying to write portable programs.  ...
  25. >
  26. >However, the argument that the behaviour should be undefined in order
  27. >to support implementations which perform pointer validity checking in
  28. >hardware is more convincing.
  29.  
  30. The language standard defines what a valid program is, and the meaning of
  31. valid programs. A particularly difficult part is deciding what the required
  32. response should be to an invalid program, or whether the standard should
  33. try to specify a response.
  34.  
  35. Some things, like invalid pointers, are impractical or impossible to diagnose
  36. until run time. (Impossible, even theoretically, for the general case.) Then
  37. the decision becomes whether to require specific run-time behavior, or
  38. constrain run-time behavior to a manageable set.
  39.  
  40. There isn't any way to predict in a platform-independent way what the
  41. range of responses might be to using an invalid pointer, so the choices
  42. boil down to requiring implementations in general to detect invalid
  43. pointers at run time, or not requiring them to detect invalid pointers.
  44.  
  45. In my view, a requirement like "must raise a signal" as the response is
  46. no better than requiring any other particular behavior. On some systems
  47. raising a signal is the default hardware response and comes for free.
  48. Other systems have no hardware detection or a different hardware
  49. response, so run-time checks would be required to avoid unpredictable or
  50. disallowed behavior. Loosening the requirement to "must raise a signal,
  51. or do A or do B or do C" doesn't change the general case. What if some
  52. platform, such as a system to be built years from now, normally reacts
  53. by doing D?
  54.  
  55. "Undefined behavior" is the way the standard says, "We don't know a good
  56. way to specify any set of behaviors for this invalid code, so we leave it
  57. up to implementors to do something that satisfies their customers."
  58.  
  59. Put another way, "undefined behavior" is a hook that allows impelementors
  60. to attach behavior that their customers want in handling potentially
  61. invalid code. On a specific system, a particular response might be
  62. expected which would be inappropriate on other systems.
  63.  
  64. ---
  65. Steve Clamage, stephen.clamage@eng.sun.com
  66. ---
  67. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  68.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  69.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  70.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  71.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  72. ]
  73.